var Types = require('Types');
cc.Class({
    'extends': cc.Component,

    properties: {
        goodContents: {
            'default': null,
            type: cc.Node },
        // optional, default is typeof default
        //    serializable: true, // optional, default is true
        //    visible: true,      // optional, default is true
        //    displayName: 'Foo', // optional
        //    readonly: false,    // optional, default is false
        goodItemPrefab: {
            'default': null,
            type: cc.Prefab
        }
    },

    // ...
    // use this for initialization
    onLoad: function onLoad() {
        // Node

        // 从常量中获取商品名称,将来从数据库获取
        this.goods = Types.Goods;
        for (var i = 0; i < this.goods.length; i++) {
            var goodItemPrefab = cc.instantiate(this.goodItemPrefab);
            this.goodContents.addChild(goodItemPrefab);
            var goodItem = goodItemPrefab.getComponent('GoodItem');
            goodItem.init(this.goods[i]);
        }
    },

    backGame: function backGame() {
        cc.director.loadScene('Game');
    }
    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});